﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using System.Reflection;
using System.Reflection.Emit;
using System.Windows.Data;

using Invini.Tools;

namespace Invini.Training
{
    public class DeferredActionTrigger : TrainingTriggerBase
    {
        public DeferredActionSync Sync
        {
            get;
            set;
        }

        public override void Prepare()
        {
            base.Prepare();

            if (this.Sync == null)
                return;

            this.Sync.Occured += this.eventOccured;
            if (this.Sync.OccuredIndicator)
                this.IsConditionSatisfied = true;
        }

        public override void Clear()
        {
            base.Clear();

            if (this.Sync != null)
                this.Sync.Clear();
        }

        private void eventOccured(DeferredActionSync sync)
        {
            this.IsConditionSatisfied = true;
        }
    }
}
